package cn.kgc.service.impl;

import java.util.List;

import cn.kgc.dao.NewsDao;
import cn.kgc.dao.impl.NewsDaoImpl;
import cn.kgc.pojo.News;
import cn.kgc.service.NewsService;

public class NewsServiceImpl implements NewsService{
	private NewsDao newsDao;
	
	public NewsServiceImpl() {
		newsDao = new NewsDaoImpl();
	}

	public List<News> getNewsList() {
		return newsDao.getNewsByList();
	}
	
	//增加新闻
	public boolean addNews(News news) {
		return newsDao.addNews(news);
	}
	
	//根据ID查询特定新闻信息
	public News getNewsById(int id) {
		return newsDao.getNewsById(id);
	}
	
	//根据ID修改特定新闻信息
	public boolean modifyNewsById(News news){
		return newsDao.modifyNewsById(news);
	}

	//根据ID删除特定新闻信息
	public boolean deleteNewsById(int id) {
		return newsDao.deleteNews2(id);
	}

	//获取新闻总数量
	public int getTotalCount() {
		return newsDao.getTotalCount();
	}

	//分页获取新闻数据
	public List<News> getPageNewsList(int pageNo, int pageSize) {
		return newsDao.getPageNewsList(pageNo, pageSize);
	}
	
	//根据CategoryId查询特定新闻信息
	public News getNewsByCategoryId(int categoryId) {
		return newsDao.getNewsByCategoryId(categoryId);
	}
}
